﻿<phone:PhoneApplicationPage 
    x:Class="ActivityTracker.Daily_CategoryBarChart"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="728" d:DesignWidth="480"
        xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"

    shell:SystemTray.IsVisible="False" Loaded="PhoneApplicationPage_Loaded">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource bipivot}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel"  Grid.Row="0" Margin="0,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Foreground="White" Text="ACTIVITY TRACKER- GROUPED BY CATEGORY" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <StackPanel x:Name="stpdate" Grid.Row="0" Orientation="Horizontal">
                <TextBlock x:Name="txtblktime" Foreground="White" Width="200" HorizontalAlignment="Center" VerticalAlignment="Center" Text="choose date" Style="{StaticResource PhoneTextTitle2Style}" ></TextBlock>
                <toolkit:DatePicker Foreground="White" x:Name="chartdtp" HorizontalAlignment="Center" VerticalAlignment="Center"></toolkit:DatePicker>
            </StackPanel>
            <StackPanel Grid.Row="1" Margin="0,0,0,0">
                <ScrollViewer x:Name="scrvwrchart" Height="540" Width="480" VerticalScrollBarVisibility="Visible">
                    <charting:Chart x:Name="barChart" Margin="6,20,13,0" MinHeight="550">
                        <charting:Chart.Series>
                            <charting:BarSeries x:Name="barseries" DependentValuePath="ActDur" IndependentValuePath="CatName" ItemsSource="{Binding}">
                                <charting:BarSeries.DependentRangeAxis>
                                    <charting:LinearAxis Minimum="0" Orientation="X" ShowGridLines="True"></charting:LinearAxis>
                                </charting:BarSeries.DependentRangeAxis>
                                <charting:BarSeries.IndependentAxis>
                                    <charting:CategoryAxis Orientation="Y">
                                        <charting:CategoryAxis.AxisLabelStyle>
                                            <Style TargetType="charting:AxisLabel">
                                                <Setter Property="Visibility" Value="Collapsed" />
                                            </Style>
                                        </charting:CategoryAxis.AxisLabelStyle>
                                    </charting:CategoryAxis>
                                </charting:BarSeries.IndependentAxis>
                                <charting:BarSeries.DataPointStyle>
                                    <Style TargetType="charting:BarDataPoint">
                                        <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}" />
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="charting:BarDataPoint">
                                                    <Grid>
                                                        <Rectangle Fill="{TemplateBinding Background}" Stroke="Black" Height="50"/>
                                                        <Grid Margin="20, -5, -350, 0" HorizontalAlignment="Left" VerticalAlignment="Center" Height="50">
                                                            <StackPanel Orientation="Horizontal">
                                                                <TextBlock Text="{TemplateBinding FormattedIndependentValue}" FontWeight="Light" Margin="2" Foreground="{StaticResource PhoneForegroundBrush}" VerticalAlignment="Center"/>
                                                            </StackPanel>
                                                        </Grid>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </charting:BarSeries.DataPointStyle>
                            </charting:BarSeries>
                        </charting:Chart.Series>
                    </charting:Chart>
                </ScrollViewer>
            </StackPanel>
            <TextBlock Grid.Row="1" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="txtblkResult" Text="Data not available for this date" Visibility="Collapsed"/>
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="btnPieChart" IconUri="/Images/piechart.png" Text="pie chart" Click="btnPieChart_Click"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    
</phone:PhoneApplicationPage>
